<!DOCTYPE html>
<html lang="en">

<head>
    <title>工厂方法模式</title>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link href="css/style.css" rel="stylesheet">
</head>

<body>
    <script>
        //安全模式创建的工厂类
        var Factory = function (type, content) {
            if (this instanceof Factory) {
                var s = new this[type](content);
                return s;
            } else {
                return new Factory(type, content);
            }
        }
        Factory.prototype = {
            java: function (content) {

            },
            javascript: function (content) {

            },
            ui: function (content) {
                this.content = content;
                (function (content) {

                })(content);
            }
        };
    </script>
</body>

</html>